#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <iterator>

using namespace std;

int iArray[10] = {1,2,3,4,5,6,7,8,9,10};
vector<int> v(iArray, iArray+10);

void display(vector<int> &v, const char *s);
unsigned int randInt(const unsigned int n);

int main()
{
    srandom(time(NULL));
    display(v, "Before shuffle: ");

    pointer_to_unary_function<unsigned int, unsigned int>
        ptr_randInt = ptr_fun(randInt);
    random_shuffle(v.begin(), v.end(), ptr_randInt);
    
    display(v, "After shuffle: ");
    
    return 0;
}

void display(vector<int> &vr, const char *s)
{
    cout << endl << s << endl;
    copy(vr.begin(), vr.end(), ostream_iterator<int>(cout, " "));
    cout << endl;
}

unsigned int randInt(const unsigned int n)
{
    return random() % n;
}
